import demo.SimpleDemo;
import org.apache.log4j.Logger;
import testcase.QuickAutoBalanceTest;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 *
 */
public class Start {
  
  private static Logger LOGGER = Logger.getLogger(QuickAutoBalanceTest.class);
  
  public static void main(String[] args) {
    Class<?> cls = null;
    if (args.length < 7) {
      LOGGER.error("request params: classname testCaseName url username password minIdle maxSize.");
      return;
    }
    try {
      cls = Class.forName(args[0]);
      Method mainMethod= cls.getDeclaredMethod("main", String[].class);
      String[] params = new String[6];
      for (int i=0;i<6;i++) {
        params[i] = args[i+1];
      }
      System.out.println("运行main方法: " + Arrays.toString(args));
      mainMethod.invoke(null, (Object) params );
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException(e);
    }

  }
}
